<?php

namespace app\api\model;

use app\api\service\Api;
use think\Db;
use think\Request;

class CategoryModel extends Api
{
    protected static $instance;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
    }

    public static function getInstance()
    {
        if (is_null(self::$instance))
        {
            self::$instance = new static();
        }
        return self::$instance;
    }

    /**
     * 获取id为下标的指定数据列表
     */
    public function column($where, $field = '*')
    {
        return Db::name('product_cate')->where($where)->column($field, 'id');
    }

    /**
     * 获取指定字段信息
     */
    public function value($where, $file = 'title')
    {
        return Db::name('product_cate')->where($where)->value($file);
    }

    /**
     * 获取指定字段列表
     */
    public function select($where, $field = '*')
    {
        return Db::name('product_cate')->where($where)->field($field)->select();
    }
}